package com.day18.ex01;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class CopyAviDemo {
    public static void main(String[] args) throws IOException {
        long startTime = System.currentTimeMillis();
        method4();
        long endTime = System.currentTimeMillis();
        System.out.println("耗时：" + (endTime - startTime));

    }
    public static void method4() throws IOException {
        BufferedInputStream bis=new BufferedInputStream(new FileInputStream("D:\\java\\javaSE\\javaSE\\src\\com\\day18\\ex01\\test.avi"));
        FileOutputStream bos=new FileOutputStream("D:\\java\\javaSE\\javaSE\\src\\com\\day18\\ex01\\test2.avi");
        byte[] bys=new byte[1024];
        int len;
        while ((len=bis.read(bys))!=-1){
            bos.write(bys,0,len);
        }
        bos.close();
        bis.close();

    }
    public static void method3() throws IOException {
        FileInputStream fis=new FileInputStream("D:\\java\\javaSE\\javaSE\\src\\com\\day18\\ex01\\test.avi");
        FileOutputStream fos=new FileOutputStream("D:\\java\\javaSE\\javaSE\\src\\com\\day18\\ex01\\test2.avi");
        int by;
        while ((by=fis.read())!=-1) {
            fos.write(by);
        }
        fos.close();
        fis.close();
    }
    public static void method2() throws IOException {
        FileInputStream fis=new FileInputStream("D:\\java\\javaSE\\javaSE\\src\\com\\day18\\ex01\\test.avi");
        FileOutputStream fos=new FileOutputStream("D:\\java\\javaSE\\javaSE\\src\\com\\day18\\ex01\\test2.avi");
        byte[] bys=new byte[1024];
        int len;
        while ((len=fis.read(bys))!=-1){
            fos.write(bys,0,len);
       }
        fos.close();
        fis.close();
    }
    public static void method1() throws IOException {
        FileInputStream fis=new FileInputStream("D:\\java\\javaSE\\javaSE\\src\\com\\day18\\ex01\\test.avi");
        FileOutputStream fos=new FileOutputStream("D:\\java\\javaSE\\javaSE\\src\\com\\day18\\ex01\\test2.avi");
        int by;
        while ((by=fis.read())!=-1) {
            fos.write(by);
        }
        fos.close();
        fis.close();
    }
}
